package com.red.star.macalline.data.mappers;

import com.red.star.macalline.data.core.base.MyMapper;
import com.red.star.macalline.data.entity.TemplateLog;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author AMGuo
 * @Description
 * @date 2018/03/28 12:06
 */
public interface TemplateLogMapper extends MyMapper<TemplateLog> {

	@Select(value = "select tt.receiver_open_id from t_template_log tt where tt.id in (select MAX(t.id) from " +
			" t_template_log t left join t_msg_template tmt on tmt.id = t.msg_template_id  where " +
			" (NOW() BETWEEN t.create_time and date_add(t.create_time, interval #{day} day)) " +
			" and t.flag = 1 and t.source = '管理员触发' and tmt.type = '电子海报消息模板' " +
			" GROUP BY t.receiver_open_id )")
	public List<String> findEffectiveOpenId(Integer day);
}
